<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
<base href="<%=basePath%>"/>
<title>soda教育</title>
<link href="qiantai/css/style.css" type="text/css" rel="stylesheet" />
<link href="qiantai/css/single.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="qiantai/js/banner1.js"></script>
<script type="text/javascript" >

/**
 * 更改密码验证
 */
function ckoldpwd() {
	var pwd = document.getElementById("oldpwd").value;
	
	var pwd1 = /^[a-zA-Z]\w{5,17}$/;
	// 正则表达式验证密码
	if (!pwd1.test(pwd)) {
		document.getElementById("spoldpwd").innerHTML = "长度必须在6-18位之间，只能包含字母，数字，下划线，";
		return false;
	}
	if (pwd1.test(pwd)) {
		document.getElementById("spoldpwd").innerHTML = "√";
		
	}
	xmlhttp = new XMLHttpRequest();
	
	xmlhttp.onreadystatechange = resp1;
	
	var n = "ajaxpwd";
	xmlhttp.open("get", ".../../QianLoginServlet?pwd=" + pwd + "&method=" + n,
			true);

	xmlhttp.send(null);
	
}
function resp1() {
	
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
			var txt = xmlhttp.responseText;
			if (txt == 0) {
				
				document.getElementById("spoldpwd").innerHTML = "原密码不正确，请重新输入";
				
				return false;
			} else {
				document.getElementById("spoldpwd").innerHTML = "√";

			}
		}
	}

}
function cknewpwd() {
	var newpwd = document.getElementById("newpwd").value;
	var oldpwd = document.getElementById("oldpwd").value;
	
	if (newpwd == oldpwd) {
		document.getElementById("spnewpwd").innerHTML = "新密码不能与原密码相同";
		return false;
	}
	if (newpwd != oldpwd) {
		document.getElementById("spnewpwd").innerHTML = "√";
		
	}
	var pwd1 = /^[a-zA-Z]\w{5,17}$/;
	
	if (!pwd1.test(newpwd)) {
		document.getElementById("spnewpwd").innerHTML = "长度必须在6-18位之间，只能包含字母，数字，下划线，";
		return false;
	}
	if (pwd1.test(newpwd)) {
		document.getElementById("spnewpwd").innerHTML = "√";
		
	}
	return true;
}
function ckrepwd() {
	var newpwd = document.getElementById("newpwd").value;
	var repwd = document.getElementById("repwd").value;
	var pwd1 = /^[a-zA-Z]\w{5,17}$/;
	if (newpwd != repwd) {
		document.getElementById("sprepwd").innerHTML = "两次密码必须一致";
		return false;
	}
	if (newpwd == repwd) {
		document.getElementById("sprepwd").innerHTML = "";
		
	}
	if (!pwd1.test(repwd)) {
		document.getElementById("sprepwd").innerHTML = "长度必须在6-18位之间，只能包含字母，数字，下划线，";
		return false;
	}
	if (pwd1.test(repwd)) {
		document.getElementById("sprepwd").innerHTML = "√";
	}
	return true;
}

function pan(){
	if(document.getElementById("spoldpwd").innerHTML=="原密码不正确，请重新输入"){
		return false;
	}
	return true;
}



function ckpwdall() {
	var flag =   cknewpwd() && ckrepwd()&&pan();
	if (flag == false) {
		alert("请输入完整的内容");
	}
	return flag;
}





</script>
</head>

<body>
<iframe style="width:100%;height:236px" scrolling="no" frameborder="0" src="qiantai/header.jsp"></iframe>

<div class="content">
   
   <div class="clear"></div>
   <div class="buyDiv">
   
   	<div class="buyHeader">
   		<h1>密码修改</h1>
   		<form action ="<%=request.getContextPath() %>/QianLoginServlet?method=xiugaipwd" method="post" onsubmit="return ckpwdall()">
   		<div class="innerDiv" onclick="history.back();">返回</div>
        <div class="innerDiv" ><input type="submit" value="修改"
							style=" border: none; background: none; 
         color: white; line-height:24px;cursor:pointer;" /></div>
   	</div>
   
   
   	<div class="loginBody">
    	<fieldset class="registField">
        	<legend style="color:#DE3237;" align="left">修改</legend>
               
               <table class="registTable">
               <tr>
               	<td align="right" style="width:30%;">原密码</td>
                <td></td>
                <td align="left"><input type="password" id="oldpwd" name="oldpwd" onblur="ckoldpwd()"/><span id="spoldpwd"></span></td>
               </tr>
               <tr>
               	<td align="right">新密码</td>
                <td></td>
                <td align="left"><input type="password" id="newpwd" name="newpwd" onblur="cknewpwd()"/><span id="spnewpwd"></span></td>
               </tr>
               <tr>
               	<td align="right">确认密码</td>
                <td></td>
                <td align="left"><input type="password" id="repwd" name="repwd" onblur="ckrepwd()"/><span id="sprepwd"></span></td>
               </tr>
               </table>
               </form>
         </fieldset>
    </div>
   </div>
   <div class="clear"></div><!--清除浮动-->
</div><!--content end-->



<div class="footer">
   <ul>
     
       
       <li class="li_left">地址：北京海淀区成府路**号</li>
       <li class="li_right">联系电话：010-82365636</li>
   </ul>
</div><!--footer end-->
<div style="display:none"><script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script></div>
</body>
</html>